package logic

import (
	"context"
	"market/internal/domain"
	"market/internal/svc"

	"grpc-common/market/types/rate"

	"github.com/zeromicro/go-zero/core/logx"
)

type UsdRateLogic struct {
	ctx                context.Context
	svcCtx             *svc.ServiceContext
	exchangeRateDomain domain.ExchangeRateDomain
	logx.Logger
}

func NewUsdRateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UsdRateLogic {
	return &UsdRateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

/*
*
逻辑处理 汇率展示
*/
func (l *UsdRateLogic) UsdRate(in *rate.RateReq) (*rate.RateRes, error) {
	// todo: add your logic here and delete this line
	usdRate := l.exchangeRateDomain.UsdRate(in.Unit)
	return &rate.RateRes{
		Rate: usdRate,
	}, nil
}
